package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceParam;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/geofence/")
public class GeofenceController {
    @Autowired
    private GeofenceService geofenceService;
    @GetMapping("select")
    public JsonResult sendGeofence(GeofenceQuery query){
        log.info("查询围栏信息，参数：{}",query);
        List<GeofenceVO> list=geofenceService.selectGeofence(query);
        log.debug("查询围栏信息成功，结果：{}",list);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult saveGeofence(GeofenceParam geofenceParam){
        log.debug("添加围栏:geofenceParam={}",geofenceParam);
        geofenceService.saveGeofence(geofenceParam);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    public JsonResult deleteGeofenceById(@PathVariable Long id){
        log.debug("删除围栏:id={}",id);
        geofenceService.deleteGeofenceById(id);
        return JsonResult.ok();
    }
}
